using B.S.Data.MES.API.Applications.BaseData.Command.MaterialGroupCommand;
using B.S.Domain.Process.ProcessrouteName;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.BaseData.CommandHandlers.MaterialGroupCommandHandlers
{
    public class GetAllProcessrouteCommandHandler : IRequestHandler<GetAllProcessrouteCommand, APIRequst<List<Processroute>>>
    {
        private readonly IBaseRepository<Processroute> _processrouteRepository;

        public GetAllProcessrouteCommandHandler(IBaseRepository<Processroute> processrouteRepository)
        {
            _processrouteRepository = processrouteRepository;
        }

        public Task<APIRequst<List<Processroute>>> Handle(GetAllProcessrouteCommand request, CancellationToken cancellationToken)
        {
            // 查询所有未删除的工艺路线
            var processroutes = _processrouteRepository.GetAll();
            return Task.FromResult(new APIRequst<List<Processroute>>
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString(),
                Data = processroutes.ToList()
            });
        }
    }
}